package com.bocim.course.dao;

import com.bocim.course.meta.Product;
import com.bocim.course.meta.ProductList;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * Created by liujunchen on 2016/11/9.
 */
public class testProduct {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-mybatis.xml");
        Productdao productdao = applicationContext.getBean("productdao", Productdao.class);
/*//        测试1
         List<Product> productList =  productdao.selectProductsbyUsers(0)  ;
        for (Product product:productList ) {
            System.out.println(product.getTitle());
            System.out.println(product.isBuy);
        }*/

//        测试2
        ProductList productList = productdao.selectProductListbyUserId(1) ;
        for (Product product :productList.getProducts())
            System.out.println(product.title+":"+productList.getUserId());

//        测试3
       /* Product product = new Product();
        product.setTitle("test2016");
        product.setBuyPrice(2016);
        product.setDetail("test1111112016");
        product.setImage("http://img14.360buyimg.com/n4/jfs/t2164/26/1839724103/328983/5483c6b7/567926a2Nd9bb1d55.jpg");
        product.setSummary("discount 2016off!");
        //product.setPublishUserId(1);
        product.setId(21);
        product.setPrice(2000);
        productdao.updateProduct(product) ;
       System.out.println( product.getId());
*/
    }
}
